package com.wwe.kotlinstudy.util

import org.jetbrains.annotations.TestOnly

/**
 * @name KotlinStudy
 * @package name：com.wwe.kotlinstudy.util
 * @anthor DavidZhang
 * @time 2018/4/26 16:16
 * @class 扩展函数的学习
 */

//为Int型添加扩展函数
fun Int.sayHello() {
    println("hello,I am anjie")
}

@TestOnly
fun test() {
    val a: Int = 2
    a.sayHello()
}

//给Int定义一个扩展属性name,它是String，太棒了
val Int.name: String
    get() = this.toString()

@TestOnly
fun test14() {
    var a: Int = 100
    println(a.name)
}